package com.test.spring.util.response;

import java.io.Serializable;

/**
 * Created by ll on 2017/2/15.
 */
public class ResponseMessage implements Serializable {

    private int code;
    private String msg;
    private Object data;

    public ResponseMessage() {
    }

    public ResponseMessage(int code, String message) {
        this.code = code;
        this.msg = msg;
    }

    public static ResponseMessage success() {
        return success(ResponseMessageCode.SUCCESS_CODE);
    }

    public static ResponseMessage success(ResponseMessageCode code) {
        ResponseMessage result = new ResponseMessage(code);
        return result;
    }

    public static ResponseMessage success(Object data) {
        ResponseMessage result = new ResponseMessage(ResponseMessageCode.SUCCESS_CODE);
        result.setData(data);
        return result;
    }

    public ResponseMessage(ResponseMessageCode code) {
        this(code.getCode(), code.getMessage());
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
